package br.usp.pcs.basys2.info;

import java.util.ArrayList;
import java.util.List;

import br.usp.pcs.basys2.Activity;

public class ProcessInfo implements Activity{

	private Integer segmentSize;
	private Integer cpuTotalTime;
	private List<ProcessInfo> childProcesses = new ArrayList<ProcessInfo>();
	private List<PeripheralActivityInfo> peripheralActivities = new ArrayList<PeripheralActivityInfo>();
	private List<FileActivityInfo> fileActivities = new ArrayList<FileActivityInfo>();
	private Long id;

	public List<Activity> getAllActivities(){
		List<Activity> activities = new ArrayList<Activity>();
		activities.addAll(childProcesses);
		activities.addAll(peripheralActivities);
		activities.addAll(fileActivities);
		return activities;
	}
	public ProcessInfo setSegmentSize(Integer segmentSize) {
		this.segmentSize = segmentSize;
		return this;
	}

	public ProcessInfo setCpuTotalTime(Integer cpuTotalTime) {
		this.cpuTotalTime = cpuTotalTime;
		return this;
	}

	public ProcessInfo setChildProcesses(List<ProcessInfo> childProcesses) {
		this.childProcesses = childProcesses;
		return this;
	}

	public ProcessInfo setSize(Integer size) {
		this.segmentSize = size;
		return this;
	}

	public ProcessInfo setPeripheralActivities(
			List<PeripheralActivityInfo> peripheralActivities) {
		this.peripheralActivities = peripheralActivities;
		return this;
	}

	public Integer getSegmentSize() {
		return segmentSize;
	}

	public Integer getSize() {
		return segmentSize;
	}

	public List<PeripheralActivityInfo> getPeripheralActivities() {
		return peripheralActivities;
	}

	public List<FileActivityInfo> getFileActivities() {
		return fileActivities;
	}

	public void setFileActivities(List<FileActivityInfo> fileActivities) {
		this.fileActivities = fileActivities;
	}

	public Integer getCpuTotalTime() {
		return cpuTotalTime;
	}

	public List<ProcessInfo> getChildProcesses() {
		return childProcesses;
	}

	public Long getId() {
		return id;
	}

	public ProcessInfo setId(Long id) {
		this.id = id;
		return this;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((childProcesses == null) ? 0 : childProcesses.hashCode());
		result = prime * result
				+ ((cpuTotalTime == null) ? 0 : cpuTotalTime.hashCode());
		result = prime * result
				+ ((fileActivities == null) ? 0 : fileActivities.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime
				* result
				+ ((peripheralActivities == null) ? 0 : peripheralActivities
						.hashCode());
		result = prime * result
				+ ((segmentSize == null) ? 0 : segmentSize.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final ProcessInfo other = (ProcessInfo) obj;
		if (childProcesses == null) {
			if (other.childProcesses != null)
				return false;
		} else if (!childProcesses.equals(other.childProcesses))
			return false;
		if (cpuTotalTime == null) {
			if (other.cpuTotalTime != null)
				return false;
		} else if (!cpuTotalTime.equals(other.cpuTotalTime))
			return false;
		if (fileActivities == null) {
			if (other.fileActivities != null)
				return false;
		} else if (!fileActivities.equals(other.fileActivities))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (peripheralActivities == null) {
			if (other.peripheralActivities != null)
				return false;
		} else if (!peripheralActivities.equals(other.peripheralActivities))
			return false;
		if (segmentSize == null) {
			if (other.segmentSize != null)
				return false;
		} else if (!segmentSize.equals(other.segmentSize))
			return false;
		return true;
	}
	
	
}
